package com.szsh.aiot.hsm.dto.gateway;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * 网关相关信息
 *
 *
 */
public class GatewayInfo {

    @SerializedName(value = "PHONE")
    private String phone;

    @SerializedName(value = "PPPOENAME")
    private String pppoename;

    @SerializedName(value = "DEVICE_OS")
    private String deviceOS;

    @SerializedName(value = "ACCESS_TIME")
    private String accessTime;

    @SerializedName(value = "BINDING_DATE")
    private String bindingDate;

    @SerializedName(value = "VENDOR")
    private String vendor;

    @SerializedName(value = "MODEL")
    private String model;

    @SerializedName(value = "MAC")
    private String mac;

    @SerializedName(value = "PROVINCE")
    private String province;

    @SerializedName(value = "CITY")
    private String city;

    @SerializedName(value = "DEV_STATUS")
    private String devStatus;

    @SerializedName(value = "NET_MODE")
    private String netMode;

    @SerializedName(value = "AREA")
    private String area;

    @SerializedName(value = "MIDDLE")
    private String middle;

    @SerializedName(value = "HARD")
    private String hard;

    private String provinceName;

    private String cityName;

    private String chipModel;

    private String gatewayVersion;

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getMiddle() {
        return middle;
    }

    public void setMiddle(String middle) {
        this.middle = middle;
    }

    public String getHard() {
        return hard;
    }

    public void setHard(String hard) {
        this.hard = hard;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPppoename() {
        return pppoename;
    }

    public void setPppoename(String pppoename) {
        this.pppoename = pppoename;
    }

    public String getDeviceOS() {
        return deviceOS;
    }

    public void setDeviceOS(String deviceOS) {
        this.deviceOS = deviceOS;
    }

    public String getAccessTime() {
        return accessTime;
    }

    public void setAccessTime(String accessTime) {
        this.accessTime = accessTime;
    }

    public String getBindingDate() {
        return bindingDate;
    }

    public void setBindingDate(String bindingDate) {
        this.bindingDate = bindingDate;
    }

    public String getVendor() {
        return vendor;
    }

    public void setVendor(String vendor) {
        this.vendor = vendor;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getDevStatus() {
        return devStatus;
    }

    public void setDevStatus(String devStatus) {
        this.devStatus = devStatus;
    }

    public String getNetMode() {
        return netMode;
    }

    public void setNetMode(String netMode) {
        this.netMode = netMode;
    }

    public String getChipModel() {
        try {
            if (!StringUtils.isEmpty(this.middle)) {
                String[] gatewayMiddleString = this.middle.split("_");
                if (gatewayMiddleString.length < 2) {
                    return "";
                }
                this.chipModel = gatewayMiddleString[gatewayMiddleString.length - 2];
                return this.chipModel;
            }
            return "";
        } catch (Exception e) {
            return "";
        }
    }

    public void setChipModel(String chipModel) {
        this.chipModel = chipModel;
    }

    public String getGatewayVersion() {
        if (!StringUtils.isEmpty(this.middle) && this.middle.startsWith("FW2.2")) {
            this.gatewayVersion = "4.0";
            return this.gatewayVersion;
        }
        if (StringUtils.isEmpty(this.deviceOS)) {
            this.gatewayVersion = "";
        } else if ("OSGI".equals(this.deviceOS)) {
            this.gatewayVersion = "1.0";
        } else if ("CTWRT".equals(this.deviceOS)) {
            this.gatewayVersion = "2.0";
        } else if ("CTWRT3".equals(this.deviceOS)) {
            this.gatewayVersion = "3.0";
        }
        return this.gatewayVersion;
    }

    public void setGatewayVersion(String gatewayVersion) {
        this.gatewayVersion = gatewayVersion;
    }

    public String getPType(){
        if ("OSGI".equals(this.deviceOS) || "CTWRT".equals(this.deviceOS)
                || "CTWRT3".equals(this.deviceOS)) {
            return "0";
        } else if ("E8C".equals(this.deviceOS)) {
            return "1";
        }
        return "";
    }

    @Override
    public String toString() {
        return "GatewayInfo{" +
                "phone='" + phone + '\'' +
                ", pppoename='" + pppoename + '\'' +
                ", deviceOS='" + deviceOS + '\'' +
                ", accessTime='" + accessTime + '\'' +
                ", bindingDate='" + bindingDate + '\'' +
                ", vendor='" + vendor + '\'' +
                ", model='" + model + '\'' +
                ", mac='" + mac + '\'' +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", devStatus='" + devStatus + '\'' +
                ", netMode='" + netMode + '\'' +
                ", area='" + area + '\'' +
                ", middle='" + middle + '\'' +
                ", hard='" + hard + '\'' +
                ", provinceName='" + provinceName + '\'' +
                ", cityName='" + cityName + '\'' +
                ", chipModel='" + chipModel + '\'' +
                ", gatewayVersion='" + gatewayVersion + '\'' +
                '}';
    }
}
